const express = require('express');
const router = express.Router();

router.get('/', (req, res) => { 
    const content = [];
    for(let i = 0; i < 100; i++)
        content.push({
            id: `2019${i}`,
            dealerId: `${i}`,
            dealerCode: `2019${i}`,
            dealerName: `总代名称${i}`,
            code: `00${i}`,
            sendBank: `银行${i}`,
            issueCountry: '中国',
            issueBank: '中国银行',
            issuePrice: '550',
            issueDate: '2019',
            validityDate: '2020',
            lcStatus: 1,
            rowVersion: 'string',
            options: [
                'receive',
                'close'
            ]
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 100,
        }
    });
});
router.get('/forPartInvoice', (req, res) => { 
    const content = [];
    for(let i = 0; i < 100; i++)
        content.push({
            id: `2019${i}`,
            dealerCode: `2019${i}`,
            dealerName: `总代名称${i}`,
            brandCode: '奇瑞',
            code: `00${i}`,
            issuePrice: '550',
            issueDate: '2019',
            lcKind: 1,
            currency: 1,
            collectionPrice: 998,
            deductionPrice: 998,
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 100,
        }
    });
});
router.get('/:id', async(req, res, next) => {
    res.json({
        message: '',
        payload: {
            id: '001',
            code: 'code001',
            dealerId: 'dealerId001',
            dealerCode: 'dealerCode001',
            dealerName: 'dealerName001',
            branchId: 'branchId001',
            branchCode: 'branchCode001',
            branchName: 'branchName001',
            brandId: 'brandId001',
            brandCode: 'brandCode',
            brandName: 'brandName',
            issueCountry: 'issueCountry',
            issueBank: 'issueBank',
            sendBank: 'sendBank',
            lcPayMentDays: 'lcPayMentDays',
            issuePrice: 'issuePrice',
            issueDate: '2019-09-01',
            lastLoadDate: '2019-10-01',
            validityDate: '2020',
            lcKind: 1,
            lcStatus: 1,
            currency: 1,
            isBatches: true,
            amount: '100',
            rowVersion: 'string',
            options: ['receive', 'close'],
            details: [
                {
                    id: '001',
                    date: '2020-04-13T02:05:58.789Z',
                    outOrIn: 'In',
                    code: 'code001',
                    partInvoiceCode: 'partInvoiceCode001',
                    amount: 22156,
                    actualDepartedDate: '2020-04-13T02:05:58.789Z',
                    partOrderPriceTerms: 1,
                    cashInDate: '2020-04-13T02:05:58.789Z'
                }
            ],
            lcCashInDetail: [
                {
                    id: '001',
                    invoiceCode: 'invoiceCode001',
                    cashInPrice: 5646545,
                    cancelBillNumber: 'code001',
                    cashInDate: '2020-04-13T02:05:58.789Z',
                    isCancel: true,
                    cancelDate: '2020-04-13T02:05:58.789Z'
                }
            ]
        }
    });
});

router.get('/:id/newRegister', async(req, res, next) => {
    res.json({
        message: '',
        payload: {
            id: '001',
            code: 'code001',
            dealerCode: 'dealerCode001',
            dealerName: 'dealerName001',
            branchCode: 'branchCode001',
            branchName: 'branchName001',
            brandCode: 'brandCode',
            brandName: 'brandName',
            issueCountry: 'issueCountry',
            issueBank: 'issueBank',
            sendBank: 'sendBank',
            lcPayMentDays: 'lcPayMentDays',
            issuePrice: 'issuePrice',
            issueDate: '2019-09-01',
            lastLoadDate: '2019-10-01',
            validityDate: '2020',
            lcKind: 1,
            lcStatus: 1,
            currency: 1,
            isBatches: true,
            amount: '100',
            options: [
                'receive',
                'close'
            ],
            lcCashInDetail: [
                {
                    invoiceCode: 'InvoiceCode001',
                    cashInPrice: '580',
                    cashInDate: '2020-01-01',
                    cancelBillNumber: 'cancelBillNumber001',
                    isCancel: true,
                    cancelDate: '2019-01-01',
                }
            ],
            lcUsedDetail: [
                {
                    saleOrderCode: 'SaleOrderCode001',
                    transBatchCode: 'TransBatchCode001',
                    transBatchPrice: '300000',
                    sapOrderCode: 'SAPOrderCode001',
                    orderPrice: '1000',
                    orderDate: '2020-02-10',
                    payMentDate: '2020-03-10',
                }
            ],
        }
    });
});

router.post('/', async(req, res, next) => {
    res.json({
        message: '登记成功'
    });
});

router.put('/:id/receive', (req, res) => {
    res.json(
        {
            message: '到款登记成功'
        }
    );
});

router.put('/:id/close', (req, res) => {
    res.json(
        {
            message: '关闭成功'
        }
    );
});

router.get('/export', async(req, res, next) => {
    res.json({
        message: 'success',
        payload: 'Mock导出'
    });
});


module.exports = router;
